Add Web Components patterns to web integration skill#13
Conversation
Comprehensive Web Components (Custom Elements) patterns showing: - Basic Custom Element with lifecycle callbacks - Attribute-based configuration - Shadow DOM encapsulation (optional pattern) - Reactive attributes with observedAttributes - Usage examples in React, Vue, Svelte, and vanilla JS - Framework-agnostic approach for maximum portability Benefits of Web Components pattern: - Works across all frameworks without modification - No framework lock-in - Standard web platform API - Ideal for component libraries and micro-frontends Updated skill description and README to highlight Web Components as framework-agnostic alternative to framework-specific patterns. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add terms for navigation, store locator, data visualization, and web components: - dropin: Android Navigation SDK NavigationView - millis: currentTimeMillis suffix - Haversine: distance calculation formula - Jenks: statistical classification method - colorbrewer: ColorBrewer color scales tool - htmlelement: Web Components HTMLElement - customelements: Web Components API - currenttime: time-related functions
| <mapbox-map | ||
| ref={mapRef} | ||
| access-token={import.meta.env.VITE_MAPBOX_ACCESS_TOKEN} | ||
| style="mapbox://styles/mapbox/standard" |
There was a problem hiding this comment.
The style property is reserved in React for the css style prop. This should be renamed to mapStyle or something similar to not throw in React.
Move Web Components to new 'Advanced Patterns' section with clear guidance: **When to use:** - Design systems & component libraries across frameworks - Micro-frontends with multiple frameworks - Multi-framework organizations - Framework migration scenarios - W3C standard for long-term stability **When NOT to use:** - Single-framework applications (use framework-specific patterns) - Need deep framework integration (hooks, composition API) - Team proficient with framework patterns - Prefer simplicity over portability Changes: - Updated skill description to focus on framework-specific patterns - Moved Web Components after all framework patterns - Added prominent warning at section start - Condensed examples (removed Shadow DOM pattern) - Clear real-world example (React/Vue/Svelte multi-framework org) Addresses feedback that web components should not be the primary pattern. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Updated: Restructured as Advanced Pattern (Option 1)Based on docs team feedback, I've restructured the Web Components section to implement Option 1 - making it clear that framework-specific patterns are the primary approach, and Web Components are an advanced pattern for specific use cases. Changes Made1. Updated skill description
2. Moved Web Components to new "Advanced Patterns" section
3. Added prominent warning at section start
4. Clearer "When to use" guidance
5. Real-world example 6. Condensed examples
ResultWeb Components are now clearly positioned as an advanced pattern for:
With clear guidance to use framework-specific patterns for typical single-framework applications. |
The 'style' attribute conflicts with React's reserved 'style' prop for CSS.
Changed to 'map-style' throughout Web Components examples:
- Updated MapboxMap class to use getAttribute('map-style')
- Updated MapboxMapReactive observedAttributes to ['center', 'zoom', 'map-style']
- Updated all usage examples (HTML, React, Vue, Svelte)
- Updated attributeChangedCallback to handle 'map-style' case
Addresses: #13 (comment)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
mattpodwysocki
left a comment
There was a problem hiding this comment.
Fixed! Changed all occurrences of style attribute to map-style to avoid conflict with React's reserved style prop.
Changes:
getAttribute('style')→getAttribute('map-style')observedAttributes: ['center', 'zoom', 'style']→['center', 'zoom', 'map-style']- All usage examples updated (HTML, React, Vue, Svelte)
attributeChangedCallbackupdated to handle'map-style'case
All examples now use:
<mapbox-map
map-style="mapbox://styles/mapbox/standard"
center="-122.4194,37.7749"
zoom="12"
/>This works safely in React and all other frameworks.
Previous warning was too strong and discouraged Web Components in general. Updated to clarify: - Web Components are great for vanilla JS apps (no added complexity) - Web Components are excellent for cross-framework scenarios - If using a framework, prefer framework-specific patterns FIRST (simpler) Key changes: - Removed "advanced pattern" and "add complexity" language - Added vanilla JavaScript as primary use case - Changed ❌ to 🔧 for framework guidance (less negative) - Added tip suggesting framework patterns first when applicable - Maintains clear guidance without discouraging Web Components generally Web Components don't add complexity to vanilla apps - they only add complexity if you're already using a framework and don't need cross- framework compatibility. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Updated: More Balanced Web Components GuidanceRevised the messaging to avoid discouraging Web Components in general. The previous warning was too strong. Key ChangesBefore:
After:
New Guidance StructureWhen to use Web Components:
When to use framework-specific patterns instead:
Added Tip:
Result
|
AndrewSepic
left a comment
There was a problem hiding this comment.
LGTM! Works as expected in the frameworks as tested. Thanks for the changes.
Summary
Adds comprehensive Web Components (Custom Elements) patterns as a framework-agnostic alternative to framework-specific integration patterns.
What's Added
New Section in SKILL.md:
connectedCallback/disconnectedCallbackobservedAttributes+attributeChangedCallbackfor live updatesPatterns Covered
Basic Web Component
Usage Across Frameworks
The same component works without modification in:
Advanced Patterns
getMap()Benefits
✅ Framework-agnostic - write once, use everywhere
✅ No framework lock-in - web platform standard
✅ Maximum portability - ideal for component libraries
✅ Future-proof - based on web standards
✅ Encapsulation - clear API via attributes
When to Use
When to Use Framework Components Instead
Testing
Addresses user request to add Web Components as framework-agnostic alternative to framework-specific patterns.